<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr = ['刘备', '张飞', '关羽'];
        console.log(arr.join('|'));
        var str = ''
        for(var i = 0;i<arr.length;i++){
            // 可以增加if  条件
            str = str + arr[i] + '|'
        }
        str = str.slice(0,str.length-1);
        console.log(str);
    </script>
</body>
</html>